package 回溯;

/**
 * todo
 *
 * @author songZiHao
 * @version 1.0.0
 * @ClassName 找出所有子集的异或总和再求和1863.java
 * @createTime 2023年04月06日 14:12:00
 */
public class 找出所有子集的异或总和再求和1863 {
	int result = 0;

	public int subsetXORSum(int[] nums) {
		backTrace(nums, 0,0);
		return result;
	}

	public void backTrace(int[] nums, int curIndex, int sum) {
		if (curIndex == nums.length) {
			result += sum;
			return;
		}
		backTrace(nums, curIndex + 1,sum^nums[curIndex]);
		backTrace(nums, curIndex + 1,sum);
	}
}
